package com.wzy.designpattern.behavioral.stategy;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-16  19:08
 */
public class PromotionStrategyFactory {
    private static Map<String, PromotionStrategy> promotionStrategyMap = new HashMap<>();
    private static final PromotionStrategy NO_PROMOTION = new EmptyPromotionStrategy();

    static {
        promotionStrategyMap.put(PromotionKey.LIJIAN, new LiJianPromotionStrategy());
        promotionStrategyMap.put(PromotionKey.MANJIAN, new ManJianPromotionStrategy());
        promotionStrategyMap.put(PromotionKey.FANXIAN, new FanXianPromotionStrategy());

    }

    private PromotionStrategyFactory() {
    }

    public static PromotionStrategy getPromotionStrategy(String PromotionStrategy) {
        com.wzy.designpattern.behavioral.stategy.PromotionStrategy strategy = promotionStrategyMap.get(PromotionStrategy);
        return strategy == null ? NO_PROMOTION : strategy;
    }

    private interface PromotionKey {
        String LIJIAN = "LIJIAN";
        String FANXIAN = "FANXIAN";
        String MANJIAN = "MANJIAN";
    }
}